﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Widgets/Widgets.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="body" runat="server">

    <div class="tabControl addSymbol">
        <a href="#" onclick="$('.addSymbol form').hide();$('#addSymbol').show()">Add Symbol</a>
        <a href="#" onclick="$('.addSymbol form').hide();$('#editSymbols').show()">Edit Symbols</a>
        <form id="addSymbol" method="post" action="<%=Url.Action("Stocks", "Widgets") %>">
            <span>Symbol:&nbsp;
            <input id="symbol" name="symbol" type="text" /></span>
            <span>Buying Price Per Share:&nbsp;$
            <input id="buyPrice" name="buyPrice" type="text" /></span>
            <span>Volume:&nbsp;
            <input id="volume" name="volume" type="text" /></span>
            <span><input name="submit" type="submit" value="Add" /></span>
            <input name="action" type="hidden" value="add" />
        </form>
        <form id="editSymbols" method="post" action="<%=Url.Action("Stocks", "Widgets") %>">
            <%
                StockCollection sc = (StockCollection) ViewData["StocksModel"];
                foreach (KeyValuePair<String, Stock> pair in sc.Stocks)
                {
                    Stock stock = pair.Value;
                    %>
                        <div>
                            <span><b><%=stock.Symbol %></b></span>
                            <span><%=stock.Name %></span>
                            <span>
                                Buying Price: $
                                <input name="buyPrice<%=stock.Symbol %>" type="text" value="<%=stock.BuyingPrice %>" />
                            </span>
                            <span>
                                Volume:
                                <input name="volume<%=stock.Symbol %>" type="text" value="<%=stock.Shares %>" />
                            </span>
                            <span>
                                <input type="button" value="Remove" onclick="$('#editAction').val('remove<%= stock.Symbol %>');$('#editSymbols').submit()" />
                            </span>
                        </div>
                    <%
                }
            %>
            <input id="editAction" name="action" type="hidden" value="save" />
            <input name="submit" type="submit" value="Save" />
        </form>
    </div>
    <%
        foreach (KeyValuePair<String, Stock> pair in sc.Stocks)
        {
            Stock stock = pair.Value;
            %>
                <div>
                    <b><%=stock.Symbol %></b>
                    <%=stock.Name %>
                    Buying Price:
                    <b>$<%=stock.BuyingPrice %></b>
                    Volume:
                    <b><%=stock.Shares %></b>
                    Current Price:
                    <b>$<%=stock.CurrentPrice %></b>
                    Profit:
                    <b>$<%=stock.Profit %></b><br />
                    <iframe allowtransparency="true" marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="no" 
                        src="http://api.finance.yahoo.com/instrument/1.0/<%=stock.Symbol %>/badge;chart=1y;quote/HTML/f.white?AppID=JI17PgC2gXbVf8vHGPRcn8S6LNUFfmBV&sig=K5e3RE9Eq5R6cGQCadDEVu5cI5I-&t=1334456811946" width="300px" height="400px"></iframe>
                </div>
            <%
        }
    %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
